package com.lucanjun.cn.springsecurity.common.config;

import com.lucanjun.cn.springsecurity.MainApplication;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lucanjun
 * @create 2025-03-10
 * @describe 自定义健康检查
 */
@Component
public class MyHealthIndicator extends AbstractHealthIndicator {

    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {

        String appStartTime = MainApplication.appStartTime;
        String appBuildTime = MainApplication.appBuildTime;
        Map<String, Object> map = new HashMap<>();
        map.put("项目打包时间", appBuildTime);
        map.put("项目启动时间", appStartTime);

        builder.up()
                .withDetails(map);
    }

}
